﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BbsbWebService.Enums;
using BbsbWebService.Classes.Plugins.Bbsb;

namespace BbsbWebService.Classes.Controllers
{
    public static class AllControllers
    {
        public static void Listen()
        {
            foreach (var controller in AppSettings.ControllersTypes)
            {
                controller.Value.Value.Listen();
            }
        }

        public static void StopListening()
        {
            foreach (var controller in AppSettings.ControllersTypes)
            {
                controller.Value.Value.StopListening();
            }
        }

        public static T GetController<T>() where T : IController
        {
            IController retVal = null;
            Type type = typeof(T);
            if (AppSettings.ControllersTypes.ContainsKey(type))
                retVal = AppSettings.ControllersTypes[type].Value;

            return (T)retVal;
        }
    }
}
